package com.crm.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.crm.dao.UserDao;
import com.crm.pojo.User;

@Transactional
public class UserService {
	private UserDao userDao;
	
	
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
	public User login(User user) {
		User u = userDao.findByUnique("username", user.getUsername());
		if(u != null && u.getPassword().equals(user.getPassword())) {
			return u;
		} else {
			return null;
		}
	}


	@Transactional(readOnly=true)
	public List<User> list() {
		return userDao.findAll();
	}

	public User get(String id) {
		return userDao.get(id);
	}
	
}
